1. Field of the Invention
The present invention relates to memory management and more particularly to object lifecycle management and improper object usage for objects having acquire-release semantics.
2. Description of the Related Art
Memory leakage has confounded software developers for decades resulting in the sometimes global distribution of bug-ridden, crash-prone software applications. Particularly in respect to those programming languages which permitted the manual allocation of memory, but also required the manual de-allocation of allocated memory, memory leakage has proven to be the principal run-time bug most addressed during the software development cycle. So prevalent a problem has memory leakage become, entire software development tools have been developed and marketed solely to address the memory leakage problem.
Memory leakage, broadly defined, is the gradual loss of allocable memory due to the failure to de-allocate previously allocated, but no longer utilized memory. Typically, memory can be reserved for data having a brief lifespan. Once the lifespan has completed, the reserved memory ought to be returned to the pool of allocable memory so that the reserved memory can be used at a subsequent time as necessary. Importantly, where memory leakage persists without remediation, ultimately not enough memory will remain to accommodate the needs of other processes.
Recognizing the importance of addressing the memory leakage problem, computer programming language theorists have developed the notion of garbage collection. Garbage collection refers to the automated analysis of allocated memory to identify regions of allocated memory containing data which no longer are required for the operation of associated processes. In the context of object oriented programming languages such as the Java™ programming language, when objects residing in memory are no longer accessible within a corresponding application, the memory allocated to the “dead” object can be returned to the pool of allocable memory.
While garbage collection can be effective in detecting orphaned objects in memory, garbage collection in the Java programming language does not account for the acquisition of other types of resources and the subsequent failure to release acquired resources. In this regard, while a resource object such as those requiring the acquisition of a file handle can be acquired within a resource object, the failure to properly release the file handle prior to the destruction of the resource object can result in the creation of an orphan file handle. The orphanage of file handles ultimately can result in the unwitting exhaustion of available file handles. To detect the unwitting orphanage of a resource object having acquire-release semantics, the resource object must be instrumented to report the occurrence of the acquisition and the release. The instrumentation of the resource object, however, can be inefficient and intrusive. Thus, developers seldom do so resulting in the failure to detect the misuse of resource objects.